import flash.display.Shape;
import CircleModel;
import flash.events.Event;

class CircleView extends AVerletView
{
  //private override var model:CircleModel;
  public function new(circleModel:CircleModel)
  {
    super(circleModel);
  }
  override private function changeHandler(event:Event)
  {
      super.changeHandler(event);
      this.alpha = cast(model,CircleModel).Alpha;
  }

  override private function draw()
  {
    var shape:Shape = new Shape();
    shape.graphics.lineStyle(1);
    shape.graphics.beginFill(model.color);
    shape.graphics.drawCircle(0, 0, cast(model,CircleModel).radius);
    shape.graphics.endFill();

    addChild(shape);
  }
  public function hit()
  {
    removeChildAt(0);
    var shape:Shape = new Shape();
    shape.graphics.lineStyle(1,0xFF0000);
    shape.graphics.beginFill(0xFF1111);
    shape.graphics.drawCircle(0, 0, cast(model,CircleModel).radius);
    shape.graphics.endFill();

    addChild(shape);
  }
  public function unHit()
  {
    removeChildAt(0);
    var shape:Shape = new Shape();
    shape.graphics.lineStyle(1);
    shape.graphics.beginFill(model.color);
    shape.graphics.drawCircle(0, 0, cast(model,CircleModel).radius);
    shape.graphics.endFill();

    addChild(shape);
  }
}